package com.xdj.chashuiwu.clause.controller;

import java.util.Arrays;
import java.util.Map;

import com.xdj.chashuiwu.clause.entity.SentenceEntity;
import com.xdj.chashuiwu.clause.service.SentenceService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.xdj.common.utils.PageUtils;
import com.xdj.common.utils.R;



/**
 * 
 *
 * @author xdj
 * @email 1226954639@qq.com
 * @date 2021-12-06 09:28:53
 */
@RestController
@RequestMapping("clause/sentence")
public class SentenceController {
    @Autowired
    private SentenceService sentenceService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("clause:sentence:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = sentenceService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{sId}")
    @RequiresPermissions("clause:sentence:info")
    public R info(@PathVariable("sId") Integer sId){
		SentenceEntity sentence = sentenceService.getById(sId);

        return R.ok().put("sentence", sentence);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("clause:sentence:save")
    public R save(@RequestBody SentenceEntity sentence){
		sentenceService.save(sentence);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("clause:sentence:update")
    public R update(@RequestBody SentenceEntity sentence){
		sentenceService.updateById(sentence);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("clause:sentence:delete")
    public R delete(@RequestBody Integer[] sIds){
		sentenceService.removeByIds(Arrays.asList(sIds));

        return R.ok();
    }

}
